/**
 * 我的资料
 * author:zhangjlt
 * date:2016年3月10日10:30:42
 */
;
define(function(require, exports, module) {
	var wechat = require("wechat");
	var template = require("template");
	var creditOrderDetail = {
		data: {},
		/**
		 * bindEvent 页面事件
		 */
		bindEvent: function() {
			//返回
			$("#return_creditorder_detail").unbind().on("click", function() {
				window.location.href = "#/index/creditOrder";
			});
		},
		/**
		 * 进行页面路由监听配置
		 */
		bindRout: function() {
			//公共页面监听路由
			Path.map("#/index/:page_name").to(function() {
				console.log(this.params["page_name"]);
				var page_name = this.params["page_name"];
				//记录状态
				common.loadPage({
					pageUrl: "html/" + page_name + ".html",
					reload: true,
					from: "left"
				});
			});
			Path.map("#home").to(function() {
				//返回首页
				common.loadPage({
					pageUrl: "html/index.html",
					reload: false,
					from: "left"
				});
			});
			//Path.root("#home");
			Path.listen();
		},
		/**
		 * 页面数据加载
		 */
		initData: function() {
			var orderId = window.localStorage.getItem("creditorderId");
			var param = {
				"openId": window.localStorage.getItem("openId"),
				"appId": window.localStorage.getItem("appId"),
				"orderId": orderId,
			};
			common.loadData({
				url: "/wxmember/service/getCreditOrderDetail",
				param: param,
				successCallBack: creditOrderDetail.getOrderDetailCallBack, //回调函数
				dataSource: "getOrderDetail"
			});

			//iscroll滚动加入
			var iscroll = require("iscroll");
			common.initIscroll({
				container: "iscrollContent_creditorder_detail",
				showScrollBar: false
			});

		},
		//callback function
		getOrderDetailCallBack: function(json) {
			console.log("调用后台ajax返回值为：" + JSON.stringify(json));
			if(json.status == "0") {
				if(json.data ) {

					creditOrderDetail.data = json;
					var html = template('creditorder_detailTemplate', creditOrderDetail.data);
					document.getElementById('main_creditorder_detail').innerHTML = html;
				} else {
					common.show_nodata("未查询到订单详情信息", "main_creditorder_detail");
					common.showTip({
						content: json.message
					});

				}
			} else {
				common.show_nodata("未查询到订单详情信息", "main_creditorder_detail");
				ommon.showTip({
					content: json.message
				});
			}
		},
		/**
		 * each page init mothed
		 */
		initialize: function() {
			
			 if(common.isWeiXin()){
            	$("#main_creditorder_detail").css("margin-top","0rem");
            
            }
			//动态加载数据
			creditOrderDetail.initData();
			//事件绑定
			creditOrderDetail.bindEvent();
			//路由绑定
			creditOrderDetail.bindRout();
		}
	};

	module.exports = creditOrderDetail;
});